<!--用户管理-->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="superTablePage">
    </ex_super_table_page>

    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="540px" :close-on-click-modal="false">
      <el-form ref="formEl" :model="formValue" :rules="rules" label-width="120px" class="common-form-panel-div"
        style="padding: 0px 10px; margin-top: 10px; ">

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_item_code')">
              <el-input v-model="formValue.subjectCode"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_item_name')">
              <el-input v-model="formValue.subjectName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_service_code_type')">
              <el-select v-model="formValue.subjectType" :placeholder="$tt('tip_please_select')" style="width: 100%;">
                <el-option
                  v-for="item in [{ label: '收入', value: 'INCOME' }, { label: '支出', value: 'OUTLAY' }, { label: '资产', value: 'ASSET' }]"
                  :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_item_remark')">
              <el-input v-model="formValue.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>



      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">{{ $tt('label_fms_account_config_cancel') }}</el-button>
        <el-button type="primary" @click="submitForm">{{ $tt('label_fms_account_config_confirm') }}</el-button>
      </div>
    </el-dialog>


  </div>
</template>
<script>

let moduleName = "label_fms_ticket_list_manager"
import superTablePageFunction from '@/mixin/super-table-page-function';
export default {

  title: moduleName,
  components: {},
  mixins: [superTablePageFunction],
  data() {

    let _this = this

    return {

      formModel: 'insert/update',

      dialogFormVisible: false,
      dialogTitle: '',
      formValue: {},
      rules: {
      }


    };
  },


  watch: {
    'formValue.companyId'(val, old) {

    }
  },

  created() {

    let _this = this

    _this.option = {
      search: {
        model: [
          { label: "label_fms_bank_card_keyword", key: "keyword", },
          {
            label: "label_status", key: "status", type: 'select', enum: 'IsAvailableStatusEnum', attrs: { clearable: true }
          }
        ],
      },
      action: [
        // {
        //   label: '新增会计科目', attrs: {icon: "el-icon-plus"}, click: () => {
        //     this.dialogTitle = '新增会计科目'
        //     this.dialogFormVisible = true
        //     this.formValue = {}
        //   }
        // },
      ],

      table: {
        url: "/fms-api/customer/CustomerTicketApplyRpc/select.json",
        attrs: {
          'cell-style': ({ row, column, rowIndex, columnIndex }) => {
            if (column.property == 'status') {
              return { color: row.status == 'NORMAL' ? this.$globalCss.successColor : this.$globalCss.infoColor }
            }
          }
        },
        model: [
          { key: 'submitUserName', label: 'label_fms_account_apply_apply_user', align: 'left' },
          { key: 'auditUserName', label: 'label_fms_account_apply_audit_user', align: 'left' },


          {
            key: 'applyTime', label: 'label_fms_account_apply_apply_date', attrs: {
              formatter: (r, c, v, i) => {
                return this.$dateFormat(v)
              }
            }
          },
          {
            key: 'ticketTime', label: 'label_fms_ticket_list_issue_date', attrs: {
              formatter: (r, c, v, i) => {
                return this.$dateFormat(v)
              }
            }
          },

          { key: 'amount', label: 'label_fms_ticket_list_invoice_amount', align: 'right' },
          {
            key: 'status', label: 'label_status',
            attrs: {
              formatter: (r, c, v, i) => {
                return this.$enumShow(v, 'FmsCreditApplyStatus')
              }
            }
          },
          {
            type: 'operate',
            operate: [

              {
                label: 'label_fms_account_apply_audit',auth:'fms_income_ticket_list_audit', click: (row) => {
                  this.dialogTitle = 'label_fms_ticket_list_apply_audit'
                  this.formValue = JSON.parse(JSON.stringify(row))
                  this.dialogFormVisible = true
                }
              }

            ],
          }
        ]
      }
    }


  },

  props: {},

  destroyed() {

  },

  methods: {

    submitForm() {

      let _this = this

      _this.$refs['formEl'].validate((valid) => {
        if (valid) {

          _this.$ajax({
            url: '/fms-api/agent/AgentSubjectRpc/saveUpdate.json',
            type: 'json',
            data: _this.formValue,
            success: (responseData) => {
              this.$message({
                showClose: true,
                message: '提交成功',
                type: 'success'
              })
              _this.$refs['superTablePage'].reload()
              _this.dialogFormVisible = false
            }
          });

        } else {
          return false;
        }

      });

    }


  }
};

</script>
<style>
.small-btn span {
  font-size: 14px;
}

.small-btn .el-button--small span {
  font-size: 14px;
}
</style>
